package com.gaoxin.api.contronller.stucontroller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.gaoxin.api.entity.stuentity.Leader;
import com.gaoxin.api.service.stuservice.QueryClassLeaderService;
import com.google.common.collect.Maps;

/**
 * 查询辅导员（班主任）信息controller
 * @author zhaozhenshe
 *2018-08-02
 */
@RestController
@RequestMapping("app/statistics")
public class QueryClassLeaderController {
	@Autowired
	private QueryClassLeaderService queryClassLeaderService;
	/**
	 * 根据部门、专业查询导员信息
	 * @param paramMap
	 * @return
	 */
	@RequestMapping(value="/queryClassLeader",method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
	public String queryClassLeader(@RequestBody Map<String, String> paramMap){
		String deptId = paramMap.get("deptId");
		String majorId = paramMap.get("majorId");
		Map<String, Object> map = Maps.newHashMap();
		String jsonData = null;
		try {
			List<Leader> list = queryClassLeaderService.findClassLeader(deptId, majorId);
			if(list.size()!=0 && list!=null){
				map.put("code", "0");
				map.put("results",list);
				jsonData = JSON.toJSONString(map);
			}else{
				map.put("code", "100102");
				map.put("errmsg", "无法查询到对应的导员信息！");
				jsonData = JSON.toJSONString(map);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jsonData;
	}
}
